package dd.control;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;

import dd.model.Event;
import dd.view.MainScreen;
import dd.view.SignInScreen;

public class JoinButtonController implements ActionListener {
	/**
	 * call when user click the join in button in the main screen go to the sign in screen
	 */
	MainScreen mainscreen;
	Event event;

	public JoinButtonController(MainScreen mc, Event event) {
		mainscreen = mc;
		this.event = event;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		JTextField textfield = mainscreen.getIDTextField();
		String id = textfield.getText();
		this.event.setEventID(id);
		// show SignInScreen
		SignInScreen signin = new SignInScreen(event);
		signin.setVisible(true);
		mainscreen.dispose();
	}
}
